Friend Class HelpForm
    Inherits QSBaseForm


#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        
    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents htmlControl As System.Windows.Forms.WebBrowser


    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.htmlControl = New WebBrowser
        Me.Panel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Panel1
        '
        Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel1.Controls.Add(Me.htmlControl)
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel1.Location = New System.Drawing.Point(0, 0)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(284, 648)
        Me.Panel1.TabIndex = 2
        '
        'htmlControl
        '
        Me.htmlControl.BackColor = System.Drawing.SystemColors.Window
        Me.htmlControl.Dock = System.Windows.Forms.DockStyle.Fill
        Me.htmlControl.Location = New System.Drawing.Point(0, 0)
        Me.htmlControl.Name = "htmlControl"
        Me.htmlControl.Size = New System.Drawing.Size(280, 644)
        Me.htmlControl.TabIndex = 0
        '
        'HelpForm
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(284, 648)
        Me.Controls.Add(Me.Panel1)
        Me.Name = "HelpForm"
        Me.ShowInTaskbar = False
        Me.Panel1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region "Singlton"

    Private Shared _instance As HelpForm = Nothing
    Private Shared _lock As Object = New Object

    '
    ' this Singleton is only used to ensure a single instance while the form is visible.
    ' that is to say it's not a memory management feature
    Public Shared ReadOnly Property Instance() As HelpForm
        Get
            If _instance Is Nothing Then
                SyncLock _lock
                    If _instance Is Nothing Then
                        _instance = New HelpForm
                    End If
                End SyncLock
            End If
            Return _instance
        End Get
    End Property

    Private Sub Form_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
        _instance = Nothing
    End Sub
    Public Shared ReadOnly Property Exists() As Boolean
        Get
            If _instance Is Nothing Then Return False
            Return True
        End Get
    End Property
#End Region


    Private WithEvents Disp As CommandDispatch = Dispatch

    Private _html As String
    Friend WriteOnly Property Html() As String
        Set(ByVal Value As String)
            _html = Value
        End Set
    End Property


    Protected Overrides Function ShowFormSetup() As Boolean
        Me.Text = "Help"
        Dim loc As Point
        loc.X = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
        loc.Y = 0
        Me.Location = loc
        Return True
    End Function

    Private Sub HelpForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        htmlControl.DocumentText = _html
    End Sub


    'Private Sub Disp_AfterShowTasks(ByVal sender As Object, ByVal ea As System.EventArgs) Handles Disp.AfterShowTasks
    '    Html = Dispatch.GetHTMLHelp
    '    HelpForm_Load(sender, ea)
    'End Sub

    Private Sub Disp_BeforeShowTasks(ByVal sender As Object, ByVal ea As System.EventArgs) Handles Disp.BeforeShowTasks
        Me.HideFormTimer.Interval += My.MySettings.Default.HelpDisplayTimeout
        Html = Dispatch.GetHTMLHelp
        HelpForm_Load(sender, ea)
    End Sub
End Class
